---
title: url
description: Creates an URL validation action.
source: /actions/url/url.ts
contributors:
  - fabian-hiller
  - depsimon
---

import { ApiList, Property } from '~/components';
import { properties } from './properties';

# url

Creates an [URL](https://en.wikipedia.org/wiki/URL) validation action.

```ts
const Action = v.url<TInput, TMessage>(message);
```

## Generics

- `TInput` <Property {...properties.TInput} />
- `TMessage` <Property {...properties.TMessage} />

## Parameters

- `message` <Property {...properties.message} />

### Explanation

With `url` you can validate the formatting of a string. If the input is not an URL, you can use `message` to customize the error message.

## Returns

- `Action` <Property {...properties.Action} />

## Examples

The following examples show how `url` can be used.

### URL schema

Schema to validate an URL.

```ts
const UrlSchema = v.pipe(
  v.string(),
  v.nonEmpty('Please enter your url.'),
  v.url('The url is badly formatted.'),
  v.endsWith('.com', 'Only ".com" domains are allowed.')
);
```

## Related

The following APIs can be combined with `url`.

### Schemas

<ApiList items={['any', 'custom', 'string']} />

### Methods

<ApiList items={['pipe']} />

### Utils

<ApiList items={['isOfKind', 'isOfType']} />
